<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>主管部门--待办工作</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/templates/act/process-xl.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<!--第一部分查询部分-->
<form class="layui-form searchForm" action="">
    查询:
    <div class="layui-input-inline">
        <input style="width:200px;" type="text" name="prjName" placeholder="项目名称" autocomplete="off"
               class="layui-input">
    </div>
    <button class="layui-btn" lay-submit lay-filter="formDemo">查询</button>
    <button class="layui-btn" lay-submit>清空</button>
</form>
<!--第二部分表头部分-->
<!--第三部分表格部分-->
<table class="layui-hide" id="dataList" lay-filter="dataList"></table>

<!--第四部分操作按钮-->
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">审批详情</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="selection">遴选详情</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="offer">确定报价详情</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="selectionBodies">遴选机构</a>
<!--
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="contract">编辑合同详情</a>
-->
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="pizhuan">批转TEST</a>
</script>

<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<script>
    var configureCom = {};
    layui.use(['jquery', 'configureCom', 'configure', 'sessionFun', 'table', 'matchDict'], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var table = layui.table;
        var sessionFun = layui.sessionFun;
        var matchDict = layui.matchDict;
        configureCom = layui.configureCom;
        var cols = [[
            {
                field: 'prjName', title: '建设项目名称', templet: function (d) {
                    return '<p>' + d.prjName + '</p><p>项目编号:</p><p>' + (d.prjCode || '-') + '</p>';
                }
            },
            {field: 'buildCorpName', title: '建设单位'},
            {
                field: 'kcCorpName', title: '勘察设计单位', templet: function (d) {
                    return '<p>勘察单位:' + (d.kcCorpName || '-') + '</p><p>设计单位:' + (d.sjCorpName || '-') + '</p>';
                }
            },
            {field: 'procDefName', title: '当前阶段'},
            {field: 'startTime', title: '到达时间'},
            {field: '', title: '当前阶段计时'},
            {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 180}
        ]];
        configureCom.tableRender(configure.PROJECT_DECLARE_LIST_HTTP, {}, cols, 'dataList', 10, 'full-200');//待办接口

        //每行操作
        table.on('tool(dataList)', function (obj) {
            var data = obj.data;
            sessionFun.set(configure.SESSION_PROJECT_LIST_DATA, data);
            nextData ={
                "taskId": data.taskId,
                "poId": data.poId
            }

            if (obj.event === 'detail') {
                editItem1('查看', configure.UNIT_PROJECT_CREATE_HTTP,nextData);//大表单  项目审批详情
            } else if(obj.event === 'selection'){
                editItem2('查看', configure.UNIT_PROJECT_CREATE_HTTP);//大表单 启动遴选
            } else if(obj.event === 'offer'){
                editItem4('查看', configure.UNIT_PROJECT_CREATE_HTTP);//大表单 确认报价
            }else if(obj.event === 'selectionBodies'){
                editItem6('查看', configure.PRJ_SELECT_DISPLAY_DECLARE_HTTP);//遴选机构
            }else if(obj.event==='pizhuan') {
                next({
                    "taskId": data.taskId,
                    "poId": data.poId
                });

            }
        });

        //待办详情 项目审批的大表单
        function editItem1(title, url,nextData) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                btnAlign: 'c',
                content: configureCom.nocache(configure.SURVEYDESIGN_WAIT_DETAILS_HTML),//
                btn: ['保存并提交','关闭'],
                yes: function (index, layero) {
                    top.layer.msg("第一个按钮")
                    next(nextData);
                    var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    var data = iframeWin.getData().then(function (res) {
                        console.log(res);
                        configureCom.postDataAjax(url, res.result).then(function (res) {
                            console.log(res);
                            top.layer.close(index);
                            top.layer.msg('保存成功！');
                            configureCom.tableReload(true);

                        });
                    });

                },
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }
        //审查机构遴选时
        function editItem2(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                btnAlign: 'c',
                btn: ['机构遴选','关闭'],
                content: configureCom.nocache(configure.SURVEYDESIGN_WAIT_DETAILS_HTML),
                yes: function (index, layero) {
                    editItem3('启动遴选', configure.PRJ_SELECT_ADD_HTTP);
                },
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }
        //启动遴选
        function editItem3(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize2,
                btnAlign: 'c',
                btn: ['启动遴选','取消'],
                content: configureCom.nocache(configure.ORG_START_SELECTION_HTML),
                yes: function (index, layero) {
                    var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    var data = iframeWin.getData().then(function (res) {
                        console.log(res);
                        configureCom.postDataAjax(configure.PRJ_SELECT_ADD_HTTP, res.result).then(function (res) {
                            top.layer.close(index);
                            top.layer.msg('启动成功！');
                            configureCom.tableReload(true);
                        });
                    });
                },
            });
        }
        //确认报价  大表单
        function editItem4(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                btnAlign: 'c',
                content: configureCom.nocache(configure.SURVEYDESIGN_WAIT_DETAILS_HTML),//
                btn: ['查看报价','关闭'],
                yes: function (index, layero) {
                    var data = sessionFun.get(configure.SESSION_PROJECT_LIST_DATA)
                    console.log(data);
                    nextData ={
                        "taskId": data.taskId,
                        "poId": data.poId
                    }
                    editItem5('查看报价',nextData);
                },
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }
        //建设主管单位确认报价时
        function editItem5(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize4,
                btnAlign: 'c',
                btn: ['确认报价','重新报价'],
                content: configureCom.nocache(configure.ORG_CONFIRM_OFFER_HTML),
                yes: function (index, layero) {
                    next(nextData)
                    /*var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    var data = iframeWin.getData().then(function (res) {
                        console.log(res);
                        configureCom.postDataAjax(url, res.result).then(function (res) {
                            console.log(res);
                            top.layer.close(index);
                            top.layer.msg('保存成功！');
                            configureCom.tableReload(true);
                        });
                    });*/
                }
            });
        }
        //遴选机构
        function editItem6(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize4,
                btnAlign: 'c',
                btn: ['遴选机构'],
                content: configureCom.nocache(configure.ORG_SELECTION_BODIES_HTML),
                yes: function (index, layero) {
                },
                success: function (layero, index) {
                    top.layer.full(index);
                }
            });
        }
        //监听搜索
        configureCom.tableSearch();
    });
</script>
</body>
</html>